PROJECT_DIR=/home/gaolinfeng/projects/nlpcoding-task/task3

echo 'Preparing dataset...'
cd $PROJECT_DIR/fairseq/examples/translation
bash prepare-iwslt14.sh

echo 'Preprocessing dataset...'
cd $PROJECT_DIR/fairseq
TEXT=examples/translation/iwslt14.tokenized.de-en
fairseq-preprocess --source-lang de --target-lang en \
    --trainpref $TEXT/train --validpref $TEXT/valid --testpref $TEXT/test \
    --destdir data-bin/iwslt14.tokenized.de-en

echo 'Training model...'
cd $PROJECT_DIR/fairseq
mkdir -p checkpoints/transformer
CUDA_VISIBLE_DEVICES=0,1
fairseq-train data-bin/iwslt14.tokenized.de-en \
    --optimizer nag --lr 0.25 --clip-norm 0.1 --dropout 0.2 --max-tokens 4000 \
    --arch transformer --save-dir checkpoints/transformer \
    --task translation \
    --source-lang de --target-lang en
